﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LibraryO2S;
public partial class Administrator_PublisherAdd : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    BizPublisher category = new BizPublisher();
    public int GetRandom()
    {
        Random rd = new Random();
        int a = rd.Next(1, 100);
        return a;
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        int status = 0;
        if (cbStatus.Checked)
        {
            status = 1;
        }
        else
            status = 0;
        try
        {

            string createdby = Session["USERNAME"].ToString();

            string filname = "";
            if (fuIcon.HasFile)
            {
                filname = GetRandom() + "" + fuIcon.FileName;
                fuIcon.SaveAs(Server.MapPath("~/Categoyicon/") + filname);
            }
            category.tblPublish_Insert(txtCategoryName.Text, int.Parse(txtSortDisplay.Text), status, filname);
            divMessage.InnerHtml = O2S_Message.Success("Hệ thống", "Thực hiện thành công");
        }
        catch (Exception ex)
        {
            divMessage.InnerHtml = O2S_Message.Error("Hệ thống", "Phát hiện lỗi" + ex.Message);
        }

    }
}